package com.rock.code.bigdata.synthesizequery.controller;

import com.rock.code.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.net.URLDecoder;

/**
 * @author piandu
 * @description 综合查询（负载均衡）
 * @date 2018/9/14 16/34
 */
@Controller
@RequestMapping("/LoadQuery")
public class LoadQueryController extends BaseController {

    //    对象查询
    @RequestMapping("/{UNIT_ID}/{START}/{END}/{SELECT}")
    public String host2(@PathVariable("UNIT_ID") String UNIT_ID, @PathVariable("START") String START,
                        @PathVariable("END") String END, @PathVariable("SELECT") String SELECT) {
        this.request.setAttribute("UNIT_ID", UNIT_ID);
        this.request.setAttribute("START", START);
        this.request.setAttribute("END", END);
        this.request.setAttribute("SELECT", SELECT);
        return "bigdata/load/queryload";
    }

    // 指标查询
    @RequestMapping("/{KPI_ID}/{KPI_NAME}/{EXT_UNIT_ID}/{START}/{END}/{SELECT}")
    public String host1(@PathVariable("KPI_ID") String KPI_ID, @PathVariable("EXT_UNIT_ID") String EXT_UNIT_ID, @PathVariable("KPI_NAME") String KPI_NAME, @PathVariable("START") String START,
                        @PathVariable("END") String END, @PathVariable("SELECT") String SELECT) throws Exception {
        this.request.setAttribute("KPI_ID", KPI_ID);
        this.request.setAttribute("EXT_UNIT_ID", EXT_UNIT_ID);
        this.request.setAttribute("KPI_NAME_DE", URLDecoder.decode(KPI_NAME, "utf-8"));
        this.request.setAttribute("START", START);
        this.request.setAttribute("END", END);
        this.request.setAttribute("SELECT", SELECT);
        return "bigdata/targets/targetView";
    }

    // 趋势预测查询
    @RequestMapping("/{KPI_CODE}/{KPI_NAME}/{EXT_UNIT_ID}")
    public String host3(@PathVariable("KPI_CODE") String KPI_CODE, @PathVariable("KPI_NAME") String KPI_NAME, @PathVariable("EXT_UNIT_ID") String EXT_UNIT_ID) throws Exception {
        this.request.setAttribute("KPI_CODE", KPI_CODE);
        this.request.setAttribute("KPI_NAME_DE", URLDecoder.decode(KPI_NAME, "utf-8"));
        this.request.setAttribute("EXT_UNIT_ID", EXT_UNIT_ID);
        return "bigdata/forecast/ForeCast";
    }

    //文件系统使用率
    @RequestMapping("/{KPI_CODE}/{KPI_NAME}/{EXT_UNIT_ID}/{ID}/{AA}")
    public String host1(@PathVariable("KPI_CODE") String KPI_CODE, @PathVariable("KPI_NAME") String KPI_NAME, @PathVariable("EXT_UNIT_ID") String EXT_UNIT_ID, @PathVariable("ID") String ID, @PathVariable("AA") String AA)throws Exception {
        this.request.setAttribute("KPI_CODE", KPI_CODE);
        this.request.setAttribute("KPI_NAME_DE", URLDecoder.decode(KPI_NAME, "utf-8"));
        this.request.setAttribute("EXT_UNIT_ID", EXT_UNIT_ID);
        this.request.setAttribute("ID", ID);
        this.request.setAttribute("AA", AA);
        return "bigdata/forecast/FileSystem";
    }
}